function getXhr(){
    var xhr = null;
    if(window.XMLHttpRequest) // Firefox et autres
        xhr = new XMLHttpRequest();
    else if(window.ActiveXObject){ // Internet Explorer
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }else { // XMLHttpRequest non supporté par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
        xhr = false;
    }
    return xhr;
}
function checkDepartment(){
    var xhr = getXhr();
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            leselect = xhr.responseText;
            document.getElementById('departement').innerHTML = leselect;
        }
    }
    xhr.open("POST","./public/index.php",true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sel = document.getElementById('region');
    ajax_region = sel.options[sel.selectedIndex].value;
    xhr.send("ajax_region="+ajax_region);
}
function checkCity(){
    var xhr = getXhr();
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            leselect = xhr.responseText;
            document.getElementById('ville').innerHTML = leselect;
        }
    }
    xhr.open("POST","./public/index.php",true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sel = document.getElementById('code_postal');
    ajax_code_postal = sel.value;
    xhr.send("ajax_code_postal="+ajax_code_postal);
}